import axios from "axios"
import { Dispatch } from "redux"
// 渲染接口
export const getList = (info?:object) => {
    return (dispatch: Dispatch) => {
        axios.get("/list",{params:info}).then(res => {
            dispatch({
                type: "LIST",
                payload: {
                    data: res.data.list,
                    ...info
                }
            })
        })
    }
}
// 添加
export const add = (id:string) => {
    return ({
        type: "ADD",
        payload:id,
   })
}

// 减少
export const low = (id: string) => {
    return ({
        type: "LOW",
        payload: id,
    })
}
// 楼层的数据
export const getTabs = () => {
    return (dispatch: Dispatch) => {
        axios.get('/tabs').then(res => {
            dispatch({
                type: 'GET_TABS',
                payload: res.data
            })
        })
    }
}

// 详情
export const getDetail = (id: string) => ({
    type: 'GET_DETAIL',
    payload: id
})

// 单选
export const checkedItem = (id: string) => {
    return {
        type: 'CHECKED_ITEM',
        payload: id,
    }
}
// 全选
export const changeAll = (cheked: boolean) => ({
    type: 'CHANGE_ALL',
    payload: cheked
})